import psycopg

with psycopg.connect("dbname=examdb user=examdb") as conn:
	with conn.cursor() as cur:
		cur.execute("DELETE FROM test_tbl1")
		conn.commit()
		# conn.rollback()
		cur.execute("SELECT sn, name FROM test_tbl1")
		for r in cur:
			print(r)

		# conn.rollback()
		raise ValueError("some wrong!")


